import axios from '../../../plugins/axios/index'
import { Message } from 'element-ui'
export default {

  /**
   * 获取我的地址信息
   */
  index (callback) {
    axios.request({
      url: 'api/home/address',
      method: 'get'
    }).then(result => callback(result.data))
  },
  /**
   * 获取创建所需要的地址信息
   */
  getAreaList (callback) {
    axios.request({
      url: 'api/home/address/create'
    }).then(res => callback(res))
  },
  /**
   * 提交数据
   * @param data
   * @param callback
   */
  sendData (data, callback) {
    // 处理传入的数据
    const area = data.area
    data.province = area[0]
    data.city = area[1]
    data.area = area[2]
    axios.request({
      url: 'api/home/address',
      method: 'post',
      data
    }).then(result => callback(result))
  },
  /**
   * 删除数据
   * @param id
   */
  delete (id) {
    axios.request({
      url: `api/home/address${id}`,
      method: 'delete'
    }).then(result => {
      // 删除成功后弹窗
      Message.success('删除成功')
    })
  },
  update (data) {
    axios.request({

    })
  }
}
